<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>02_CSS选择器</title>
    <style>
        /*1.标签名选择器*/
        h4 {
            color: green;
        }
        /*2.id选择器：选中指定id值的唯一一个元素*/
        #dd1 {
            width: 100px;
            height: 50px;
            background-color: yellow;
        }
        /*3.类选择器*/
        .msg {
            color: white;
        }
        .error {
            background-color: red;
        }
        .true {
            background-color: green;
        }
        /*4.伪类选择器*/
        a:link {/*超链接未被访问过的状态*/
            color: gray;
        }
        a:visited {/*超链接已经被访问过的状态*/
            color:green;
        }
        a:hover {/*元素悬停的状态*/
            color:orange;
        }
        a:active {/*超链接激活时的状态*/
            color:red;
        }
        /*5.群组选择器*/
        #dd1,.error {
            border: 1px solid deeppink;
        }
        /*6.后代选择器*/
        #dd2 span {
            background-color: aqua;
        }
        /*7.子代选择器*/
        #dd2>div>p>span {
            color: yellow;
        }
    </style>
</head>
<body>
    <div>我是块级元素</div>
    <div id="dd1">我是块级元素</div>
    <p>我是段落</p>
    <h4>我是标题</h4>
    <h4>我是标题</h4>
    <hr>


    <span class="error msg">用户名被占用</span>
    <span class="error msg">密码不能少于8位</span>
    <span class="error msg">手机号不合法</span><br>
    <span class="true msg">用户名正确</span>
    <span class="true msg">两次输入密码一致</span>
    <span class="true msg">验证码正确</span>
    <hr>


    <a href="https://www.baidu.com">超链接1</a>
    <a href="http://">超链接2</a>
    <hr>

<div id="dd2">
    <span>111</span>
    <div>
        <span>222</span>
        <p>测试文字</p>
        <p>测试<span>333</span>文字</p>
    </div>
    <span>444</span>
</div>
</body>
</html>